package org.zizi.modal;

import java.util.Date;

/**
 * 专用发票部分：同一纳税人同一项目内容，只能有一条记录
 * 普通手工发票部分：同一纳税人同一项目内容，一年只能有一条
 * 定额发票部分：同一纳税人同一项目内容，一年只能有一条（和普通手工发票相冲突，即手工有了，定额就不能有）
 * 其它发票部分：无要求
 * 
 * 
 * @author zizi
 *
 */
public class VatCreditInvoice implements Bean
{
	private static final long serialVersionUID = 1L;
	
	public static final String SEP = "增值税专用发票";
	public static final String MAN = "通用手工发票";
	public static final String FIX = "定额发票";
	public static final String OTH = "其它发票";
	public static final String ALL[] = { SEP, MAN, FIX, OTH };
	
	private long vatCreditId;				//属于的哪个表单
	private String invoiceCategory;			//类型：增值税专用发票、通用手工发票、定额发票、其它发票
	private String invoiceCode;				//代码
  	private String invoiceNum;				//号码
  	private Long invoiceTypeId;				//项目内容
  	private Double invoiceMoney;			//金额
  	private Date invoiceDate;				//日期
  	private int place;						//存放排序
  	
  	private VatType type;
  	
	public long getVatCreditId()
	{
		return vatCreditId;
	}
	public void setVatCreditId(long vatCreditId)
	{
		this.vatCreditId = vatCreditId;
	}
	public String getInvoiceCategory()
	{
		return invoiceCategory;
	}
	public void setInvoiceCategory(String invoiceCategory)
	{
		this.invoiceCategory = invoiceCategory;
	}
	public String getInvoiceCode()
	{
		return invoiceCode;
	}
	public void setInvoiceCode(String invoiceCode)
	{
		this.invoiceCode = invoiceCode;
	}
	public String getInvoiceNum()
	{
		return invoiceNum;
	}
	public void setInvoiceNum(String invoiceNum)
	{
		this.invoiceNum = invoiceNum;
	}
	public Long getInvoiceTypeId()
	{
		return invoiceTypeId;
	}
	public void setInvoiceTypeId(Long invoiceTypeId)
	{
		this.invoiceTypeId = invoiceTypeId;
	}
	public Double getInvoiceMoney()
	{
		return invoiceMoney;
	}
	public void setInvoiceMoney(Double invoiceMoney)
	{
		this.invoiceMoney = invoiceMoney;
	}
	public Date getInvoiceDate()
	{
		return invoiceDate;
	}
	public void setInvoiceDate(Date invoiceDate)
	{
		this.invoiceDate = invoiceDate;
	}
	public int getPlace()
	{
		return place;
	}
	public void setPlace(int place)
	{
		this.place = place;
	}
	public VatType getType()
	{
		return type;
	}
	public void setType(VatType type)
	{
		this.type = type;
	}
	
	/** 检查发票类型是否正确 */
	public void checkInvoiceCategory()
	{
		if (invoiceCategory == null) throw new NullPointerException("发票类型不能为空。");
		
		boolean exist = false;
		for (int i = 0; i < ALL.length; i++)
		{
			String c = ALL[i];
			exist = c.equals(invoiceCategory);
			if (exist) break;
		}
		
		if (!exist) throw new IllegalArgumentException("发票类型错误：" + invoiceCategory);
	}
	
	/** 是否是专用发票 */
	public boolean isSepInvoice()
	{
		return SEP.equals(invoiceCategory);
	}
	
	/** 是否是普通发票 */
	public boolean isNorInvoice()
	{
		return MAN.equals(invoiceCategory) || FIX.equals(invoiceCategory);
	}
	
	/** 是否是其它发票 */
	public boolean isOthInvoice()
	{
		return OTH.equals(invoiceCategory);
	}
}